﻿@using ECGadmin.Common
@using ECGadmin.WebUI.CustomHelpers
@model BannerImageDto

<div class="box-Info hidden">
    <div class="Info-header">
        <span>Thêm ảnh Banner</span>
    </div>

    <div class="Info-body ib-infopro">
        <table class="p-img-info table-odd" cellpadding="10" id="banner-image-list">
            <colgroup>
                <col style="width: 100px;" />
                <col />
                <col />
                <col />
                <col />
                <col style="width: 70px;" />
                <col style="width: 70px;" />
                <col style="width: 70px;" />
                <col style="width: 70px;" />
                <col style="width: 60px;" />
            </colgroup>
            <tr class="banner-image-title">
                <th scope="col">Ảnh</th>
                <th scope="col">Tựa đề</th>
                <th scope="col">Mô tả</th>
                <th scope="col">Url</th>
                <th scope="col">Url Google analytic</th>
                <th scope="col">Độ rộng</th>
                <th scope="col">Độ cao</th>
                <th scope="col">Thứ tự</th>
                <th scope="col">Hiển thị</th>
                <th scope="col"></th>
            </tr>
            @foreach (var item in (List<BannerImageDto>)ViewBag.BannerImageList)
            {
                <tr id="@string.Format("bni-{0}", item.BannerImageId)">
                    <td>
                        <img src="@string.Format("{0}", item.ImagePath.ImagePathThumb(50, 50))" />
                    </td>
                    <td>@item.Title</td>
                    <td>@item.Description </td>
                    <td>
                        <a href="@item.Url">@item.Url</a>
                    </td>
                    <td>
                        <a href="@item.UrlStatistic">@item.UrlStatistic</a>
                    </td>
                    <td>@item.Width</td>
                    <td>@item.Height</td>
                    <td>@item.Order</td>
                    <td>
                        <input type="checkbox" @string.Format("{0}", item.Show ? "checked" : "") />
                    </td>
                    <td>
                        @Ajax.ActionLink("sửa", "AjaxEditBannerImage", "Banner", new { bannerImageId = item.BannerImageId },
                                                new AjaxOptions
                                                {
                                                    OnSuccess = "AjaxResultEditBannerImage"
                                                }, new { @class = "icon-edit-v2 fl-l bootstrapTangoSmall" })

                        @Ajax.ActionLink("Xoa", "AjaxDeleteBannerImage", "Banner", new { bannerImageId = item.BannerImageId, imagePath = item.ImagePath },
                                                new AjaxOptions
                                                {
                                                    Confirm = "Bạn chắc chắn muốn xóa ảnh này!",
                                                    OnSuccess = "AjaxResultDeleteBannerImage"
                                                }, new { @class = "icon-delete fl-l bootstrapTangoSmall" })
                    </td>
                </tr>
            }
        </table>

        <div class="banner-wrapper">
            @using (Html.BeginForm("UploadBannerImage", "Banner", FormMethod.Post, new { enctype = "multipart/form-data", id = "ImgForm", name = "ImgForm", target = "UploadTarget" }))
            {
                @Html.Hidden("BannerId", (string)ViewBag.BannerId)
                <table class="table-info create-banner-image">
                    <tr>
                        <td class="tInfoLeft">Upload ảnh
                        </td>
                        <td class="tInfoRight">
                            <input type="file" name="imageFile" />
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Tựa đề
                        </td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.Title, new { @class = "pimDescription" })
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Mô tả ngắn
                        </td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.Description, new { @class = "pimDescription" })
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Url
                        </td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.Url)
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Url Google Analytic
                        </td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.UrlStatistic)
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Thứ tự</td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.Order, new { @class = "pimOrdering" })
                            @Html.ValidationMessageFor(m => m.Order)
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Hiển thị</td>
                        <td class="tInfoRight">
                            @Html.CheckBoxFor(m => m.Show, new { @class = "pimActive" })
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Độ rộng</td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.Width)
                            @Html.ValidationMessageFor(m => m.Width)
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft">Độ cao</td>
                        <td class="tInfoRight">
                            @Html.TextBoxFor(m => m.Height)
                            @Html.ValidationMessageFor(m => m.Height)
                        </td>
                    </tr>
                    <tr>
                        <td class="tInfoLeft"></td>
                        <td class="tInfoRight">
                            <input type="button" value="Save Image" onclick="UploadImage()" id="btnSaveImage" />
                        </td>
                    </tr>
                </table>
            }
            <iframe id="UploadTarget" name="UploadTarget" onload="UploadImage_Complete();" style="position: absolute; left: -999em; top: -999em;"></iframe>
        </div>

    </div>
</div>
